home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 24 / AACD 24.iso / AACD / Online / binbatchpost / binarybatchpost.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  2001-07-24  |  19.9 KB  |  794 lines

  1. /* Binary Batch Post */
  2.  
  3. /* NewsRog ARexx Script */
  4.  
  5. /* A script for easily posting multiple binary files to newsgroups */
  6.  
  7. /* Copyright © 2000 - 2001 Duncan Taylor */
  8. /*  duncan@hiarchive.f9.co.uk  */
  9. /* Version 1.2 (21-Jul-2001) */
  10.  
  11. /* **************** NOTE **************************/
  12.  
  13. /* As the following cannot be set via ARexx, you must configure NewsRog */
  14.  
  15. /* Line Wrap option must be turned OFF */
  16. /* "Program Options/Post Options" "Post Wrap Mode" = Never */
  17.  
  18. /* The following Custom Headers are required */
  19. /* HEADER                       VALUE                                              MODE    GROUP PATT     */
  20. /* Content-Type:                Multipart/Mixed; Boundary=NewsRog-Boundary-2000    Any     *.binaries.*   */
  21. /* Content-Transfer-Encoding    7Bit                                               Any     *.binaries.*   */
  22. /* Content-Disposition:         Inline                                             Any     *.binaries.*   */
  23.  
  24. /*************** REQUIREMENTS *********************/
  25.  
  26. /* NewsRog (Version 1.8b) */
  27.  
  28. /* rexxreqtools.library (Aminet /util/rexx/RexxReqTools.lha) */
  29.  
  30. /* Base 64 Encoder. This script is configured to use: */
  31. /* Base64Encode (Aminet /comm/mail/Base64Coders.lha) */
  32. /* Although it should be possible to configure the script to use a */
  33. /* different Base 64 Encoder... */
  34.  
  35. /* MrSPLIT for use with Multipart Binary posts */
  36. /* (Aminet /util/cli/MrSPLIT.lha) */
  37. /* You could use a different split program, but it would mean changing */
  38. /* parts of this script - so only try it if you know what you're doing :) */
  39.  
  40.  
  41. /*************************************************/
  42.  
  43. /* Allow commands to return results */
  44.  
  45. options results
  46.  
  47. /* Deal with errors */
  48.  
  49. options failat 21
  50.  
  51. /* BEGIN PROGRAM */
  52.  
  53. /****************************************************************/
  54. /****** SET VARIOUS PATHS  - YOU MUST CHANGE THESE VALUES *******/
  55. /****************************************************************/
  56.  
  57. newsrog_path = 'System:Netware/NewsRog/NewsRog'
  58. temp_path = 'T:'   /* This must include the trailing / if it ends with a directory */
  59. sig_path = 'YAM:.signature'
  60. base64_path = 'C:Base64Encode'
  61. base64_args = 'NOHEADER'
  62. split_path = 'C:MrSPLIT'
  63. default_binary_path = 'Internet:Web/TVCaptures'  /* No need for the trailing / */
  64.  
  65. /****************************************************************/
  66.  
  67. /* Initialisation */
  68.  
  69. NEWS_PORT = 'NEWSROG'
  70.  
  71. title = ' Binary Batch Post by Duncan Taylor (21-Jul-2001) '
  72. subject_text = ' Enter Subject. The filename will be added automatically '
  73. group_text = ' Enter Group to post to '
  74. body_text = ' Enter text to be include in the body of the message.' '0a'X ,
  75.  ' The filename and total number of files will be added automatically '
  76. files_text = ' Select binary files to post '
  77. body_file_text = ' Select text file to include in body of message '
  78. contact_query = ' Do you want to post Contact Sheets (Thumbnail Indexes)? '
  79. contact_text = ' Select Contact Sheets '
  80. mime_text = ' Enter MIME type for binary files '
  81. post_query = ' Do want want to post artciles now or later? '
  82. online_query = ' NewsRog is not currently Online '
  83. offline_text = ' NewsRog cannot go Online now '
  84.  
  85. newsrog_error_text = '   Unable to launch NewsRog   '
  86.  
  87. ok_buttons = 'OK'
  88. y_or_n_buttons = '_Yes | _No '
  89.  
  90. /* Check if rexxreqtools.library/rexxsupport.library is installed */
  91.  
  92. IF ~EXISTS('Libs:rexxreqtools.library') then
  93. CALL library_error()
  94. IF ~EXISTS('Libs:rexxsupport.library') then
  95. CALL library_error()
  96.  
  97. /* Add rexxreqtools.library/rexxsupport.library to functions */
  98.  
  99. IF ~SHOW('L','rexxreqtools.library') then
  100. ADDLIB('rexxreqtools.library', 0, -30, 0)
  101. IF ~SHOW('L','rexxsupport.library') then
  102. ADDLIB('rexxsupport.library', 0, -30, 0)
  103.  
  104. /* Check config */
  105.  
  106. IF ~EXISTS(newsrog_path) THEN
  107. CALL newsrog_path_error()
  108.  
  109. IF ~EXISTS(temp_path) THEN
  110. CALL temp_path_error()
  111.  
  112. IF ~EXISTS(base64_path) THEN
  113. CALL base64_path_error()
  114.  
  115.  
  116. /* If NewsRog isn't running, try to lauch it */
  117.  
  118. IF ~SHOW('P',NEWS_PORT) THEN
  119. DO
  120.  ADDRESS COMMAND
  121.  'RUN >NIL:' newsrog_path
  122.  'SYS:REXXC/WaitForPort' NEWS_PORT
  123.  IF RC>0 THEN
  124.  DO
  125.   newsrog_error = RTEZREQUEST(newsrog_error_text,ok_buttons,title,,)
  126.   IF newsrog_error=0 THEN
  127.   EXIT
  128.  END
  129. END
  130.  
  131. /* Open Post Queue window */
  132.  
  133. ADDRESS (NEWS_PORT)
  134.  
  135. ISWINDOWOPEN POSTS
  136. IF RC=0 THEN
  137. OPENWINDOW POSTS
  138.  
  139.  
  140. /* Create posts */
  141.  
  142. /* Determine number of subscribed newsgroups */
  143.  
  144. GROUPCOUNT
  145. NUMBER_GROUPS = result
  146.  
  147. GETGROUP 0
  148. GROUP_0 = result
  149.  
  150. /* Determine names of subscribed newsgroups */
  151.  
  152. DO j=1 to NUMBER_GROUPS 
  153. GETGROUP j-1
  154. GROUP_NAME.j = result
  155. END
  156.  
  157. /* Select binary newsgroups */
  158.  
  159. BINARY_GROUPS = 0
  160. DO k=1 to NUMBER_GROUPS
  161.  binary = INDEX(GROUP_NAME.k, 'binaries')
  162.   IF binary > 0 THEN
  163.    DO
  164.     BINARY_GROUPS = BINARY_GROUPS + 1
  165.     BINARY_NAME.BINARY_GROUPS = GROUP_NAME.k
  166.    END
  167. END
  168.  
  169. /* Ask user for group to post to */
  170.  
  171. GROUP_LIST = ''
  172. DO l=1 to BINARY_GROUPS
  173. GROUP_LIST = GROUP_LIST||BINARY_NAME.l '|'
  174. END
  175. GROUP_CROSS_1 = GROUP_LIST||'Other'
  176. GROUP_LIST = GROUP_LIST||'Cross Post |Other'
  177.  
  178. group_number = RTEZREQUEST('Select group to post to:',GROUP_LIST)
  179.  
  180. IF group_number = 0 THEN
  181. DO
  182.  group = RTGETSTRING(,group_text,title,,)
  183.   IF rtresult = 0 THEN
  184.   EXIT
  185. END
  186. IF group_number = BINARY_GROUPS + 1 THEN
  187.       DO
  188.          group_cross_number = RTEZREQUEST('Select first group to cross post to:',GROUP_CROSS_1)
  189.             IF group_cross_number = 0 THEN
  190.             DO
  191.                group = RTGETSTRING(,group_text,title,,)
  192.                   IF rtresult = 0 THEN
  193.                     EXIT
  194.                group_cross_number_2 = RTEZREQUEST('Select second group to post to:',GROUP_CROSS_1)
  195.                   IF group_cross_number_2 = 0 THEN
  196.                         DO
  197.                         group = group||',' RTGETSTRING(,group_text,title,,)
  198.                         IF rtresult = 0 THEN
  199.                           EXIT
  200.                         END
  201.                   ELSE
  202.                         group = group||',' BINARY_NAME.group_cross_number_2
  203.             END
  204.          ELSE
  205.             DO
  206.                group = BINARY_NAME.group_cross_number
  207.                   DO s = 1 to BINARY_GROUPS - 1
  208.                         IF s ~= group_cross_number THEN       
  209.                            BINARY_NAME.s = BINARY_NAME.s
  210.                         ELSE
  211.                            DO
  212.                            t = s + 1 
  213.                            BINARY_NAME.s = BINARY_NAME.t
  214.                            END
  215.                   END
  216.                GROUP_LIST_2 = ''
  217.                DO u = 1 to BINARY_GROUPS - 1
  218.                GROUP_LIST_2 = GROUP_LIST_2||BINARY_NAME.u '|'
  219.                END
  220.                GROUP_LIST_2 = GROUP_LIST_2||'Other'
  221.                group_cross_number_2 = RTEZREQUEST('Select second group to post to:',GROUP_LIST_2)
  222.                   IF group_cross_number_2 = 0 THEN
  223.                      DO
  224.                         group = group||',' RTGETSTRING(,group_text,title,,)
  225.                         IF rtresult = 0 THEN
  226.                            EXIT
  227.                      END
  228.                   ELSE
  229.                         group = group||',' BINARY_NAME.group_cross_number_2
  230.                     END
  231.       END
  232.  
  233. ELSE
  234.  group = BINARY_NAME.group_number
  235.  
  236.  
  237. /* Ask whether single part posts or multipart posts */
  238.  
  239. multipart = RTEZREQUEST('Select type of post:','Single Part|Multi Part',title)
  240.    IF multipart = 1 THEN
  241.  
  242. DO
  243.  
  244. /* Ask user for subject */
  245.  
  246. subject = RTGETSTRING(,subject_text,title,ok_buttons,)
  247.  
  248. /* Ask user for body text */
  249.  
  250. body = RTGETSTRING(,body_text,title,ok_buttons,)
  251.  
  252. /* Wrap body text to 78 columns */
  253.  
  254. body. = ''
  255. EndPos = length(body); WrapPos = 1
  256.  
  257. DO n = 1 while EndPos <= length(body)
  258.  EndPos = lastpos(' ',body' ', WrapPos + 79)
  259.  body.n = substr(body, WrapPos, EndPos-WrapPos)
  260.  WrapPos = EndPos + 1
  261. end
  262. body.0 = n-1
  263.  
  264. /* Ask user for MIME type setting (default Image/JPEG) */
  265.  
  266. mime_type = RTGETSTRING('Image/JPEG',mime_text,title,ok_buttons,)
  267. IF rtresult = 0 THEN
  268. mime_type = 'Image/JPEG'
  269.  
  270. /* Ask user if they want to post Contact Sheets (Thumbnail Indexes) */
  271.  
  272. contacts = rtezrequest(contact_query,y_or_n_buttons,title,'rtez_defaultresponse = 0')
  273. IF contacts = 1 THEN
  274. DO
  275.  call rtfilerequest(default_binary_path,,contact_text, , "rtfi_flags=freqf_multiselect",contactimages)
  276.  
  277.  /* Base64 encode Contact Sheets */
  278.  
  279.  DO o=1 to contactimages.count
  280.  
  281.  ADDRESS COMMAND
  282.  
  283.  base64_path '"'||contactimages.o||'"' '"'||temp_path||contactimagestext.o||'"' base64_args '>NIL:'
  284.  DivPos = Max(lastpos(':', contactimages.o), lastpos('/', contactimages.o)) +1
  285.  contactimagename.o = substr(contactimages.o, DivPos)
  286.  
  287. /* Find file length */
  288.  
  289.  'run >nil: list "'||contactimages.o||'" LFORMAT %L to pipe:size'||o
  290.  
  291.  ADDRESS (NEWS_PORT)
  292.    IF OPEN('FileSize', 'pipe:size'||o, 'R') THEN
  293.    contactbytes.o = READLN('FileSize')
  294.    CLOSE('FileSize') 
  295.  END 
  296. END
  297.  
  298. /* Ask user to select binary files (jpegs) to be posted */
  299.  
  300. call rtfilerequest(default_binary_path,,files_text, , "rtfi_flags=freqf_multiselect",images)
  301. IF images = 0 THEN
  302. EXIT
  303.  
  304. /* Base64 encode binary files */
  305.  
  306. DO m=1 to images.count
  307.  
  308. ADDRESS COMMAND
  309.  
  310.  base64_path '"'||images.m||'"' '"'||temp_path||imagestext.m||'"' base64_args '>NIL:'
  311.  DivPos = Max(lastpos(':', images.m), lastpos('/', images.m)) +1
  312.  imagename.m = substr(images.m, DivPos)
  313.  
  314. /* Find file length */
  315.  
  316.  'run >nil: list "'||images.m||'" LFORMAT %L to pipe:size'||m
  317.  
  318. ADDRESS (NEWS_PORT)
  319.   IF OPEN('FileSize', 'pipe:size'||m, 'R') THEN
  320.   bytes.m = READLN('FileSize')
  321.   CLOSE('FileSize') 
  322. END 
  323.  
  324. /* **** CONTACT SHEETS **** */
  325.  
  326. /* Set up MIME header for each file */
  327.  
  328. IF contacts = 1 THEN DO
  329.  
  330. DO p = 1 to contactimages.count
  331.  
  332. OPEN('CNT-Temp'||p, temp_path||'CNT-Temp'||p, 'W')
  333. WRITELN('CNT-Temp'||p, 'This is a multi-part message in MIME format.')
  334. WRITELN('CNT-Temp'||p, '--NewsRog-Boundary-2000')
  335. WRITELN('CNT-Temp'||p, 'Content-Type: Text/Plain; Charset=ISO-8859-1')
  336. WRITELN('CNT-Temp'||p, 'Content-Transfer-Encoding: 7Bit')
  337. WRITELN('CNT-Temp'||p, '')
  338. CLOSE('CNT-Temp'||p)
  339.  
  340. /* Add body text to message */
  341.  
  342.  OPEN('CNT-Temp'||p, temp_path||'CNT-Temp'||p, 'A')
  343. DO r = 1 to body.0
  344.  WRITELN('CNT-Temp'||p, body.r)
  345. END
  346.  WRITELN('CNT-Temp'||p, '')
  347.  WRITELN('CNT-Temp'||p, contactimagename.p)
  348.  WRITELN('CNT-Temp'||p, '(Contact Sheet '||p 'of' contactimages.count||')')
  349.  WRITELN('CNT-Temp'||p, '')
  350.  CLOSE('CNT-Temp'||pi)
  351.  
  352. /* Add signature to message */
  353.  
  354. OPEN('Sig', sig_path, 'R')
  355. OPEN('CNT-Temp'||p, temp_path||'CNT-Temp'||p, 'A')
  356. DO UNTIL EOF('Sig')
  357.  sig_line = READLN('Sig')
  358.  WRITELN('CNT-Temp'||p, sig_line)
  359. END
  360. CLOSE('Sig')
  361. CLOSE('CNT-Temp'||p)
  362.  
  363. /* Add intermediatary MIME information */
  364.  
  365. OPEN('CNT-Temp'||p, temp_path||'CNT-Temp'||p, 'A')
  366. WRITELN('CNT-Temp'||p, '--NewsRog-Boundary-2000')
  367. WRITELN('CNT-Temp'||p, 'Content-Disposition: Inline; filename='||contactimagename.p)
  368. WRITELN('CNT-Temp'||p, 'Content-Type:' mime_type||'; name='||contactimagename.p)
  369. WRITELN('CNT-Temp'||p, 'Content-Transfer-Encoding: Base64')
  370. WRITELN('CNT-Temp'||p, '')
  371. CLOSE('CNT-Temp'||p)
  372.  
  373. /* Insert Base64 Encoded Data */
  374. OPEN('ContactImage', temp_path||contactimagestext.p, 'R')
  375. OPEN('CNT-Temp'||p, temp_path||'CNT-Temp'||p, 'A')
  376. DO UNTIL EOF('ContactImage')
  377. contactimage_line = READLN('ContactImage')
  378. WRITELN('CNT-Temp'||p, contactimage_line)
  379. END
  380. CLOSE('ContactImage')
  381. CLOSE('CNT-Temp'||p)
  382.  
  383.  
  384. /* Add closing MIME information */
  385.  
  386. OPEN('CNT-Temp'||p, temp_path||'CNT-Temp'||p, 'A')
  387. WRITELN('CNT-Temp'||p, '--NewsRog-Boundary-2000')
  388. CLOSE('CNT-Temp'||p)
  389.  
  390. /* Add Contact Sheet posts to queue */
  391.  
  392.  
  393.  
  394.  ADDPOST
  395.  POSTNUMBER = result
  396.  
  397. /* Set post group */
  398.  
  399.  POSTCMD POSTNUMBER SETGROUPS group
  400.  
  401. /* Set post subject */
  402.  
  403.  POSTCMD POSTNUMBER SETSUBJ subject ' - Contact Sheet' p 'of' contactimages.count '('||contactbytes.p 'bytes)'
  404.  
  405.  POSTCMD POSTNUMBER INSFILE temp_path||'CNT-Temp'||p
  406.  
  407. /* Clean up temp location */
  408.  
  409. ADDRESS COMMAND
  410. 'run >NIL: delete' temp_path||contactimagestext.p
  411. 'run >NIL: delete' temp_path||'CNT-Temp'||p
  412.  
  413. ADDRESS (NEWS_PORT)
  414.  
  415. END
  416. END
  417.  
  418. /* **** FILES **** */
  419.  
  420. /* Set up MIME header for each file */
  421.  
  422. DO i = 1 to images.count
  423.  
  424. OPEN('MSG-Temp'||i, temp_path||'MSG-Temp'||i, 'W')
  425. WRITELN('MSG-Temp'||i, 'This is a multi-part message in MIME format.')
  426. WRITELN('MSG-Temp'||i, '--NewsRog-Boundary-2000')
  427. WRITELN('MSG-Temp'||i, 'Content-Type: Text/Plain; Charset=ISO-8859-1')
  428. WRITELN('MSG-Temp'||i, 'Content-Transfer-Encoding: 7Bit')
  429. WRITELN('MSG-Temp'||i, '')
  430. CLOSE('MSG-Temp'||i)
  431.  
  432. /* Add body text to message */
  433.  
  434.  OPEN('MSG-Temp'||i, temp_path||'MSG-Temp'||i, 'A')
  435. DO q = 1 to body.0
  436.  WRITELN('MSG-Temp'||i, body.q)
  437. END
  438.  WRITELN('MSG-Temp'||i, '')
  439.  WRITELN('MSG-Temp'||i, imagename.i)
  440.  WRITELN('MSG-Temp'||i, '(Image '||i 'of' images.count||')')
  441.  WRITELN('MSG-Temp'||i, '')
  442.  CLOSE('MSG-Temp'||i)
  443.  
  444. /* Add signature to message */
  445.  
  446. OPEN('Sig', sig_path, 'R')
  447. OPEN('MSG-Temp'||i, temp_path||'MSG-Temp'||i, 'A')
  448. DO UNTIL EOF('Sig')
  449.  sig_line = READLN('Sig')
  450.  WRITELN('MSG-Temp'||i, sig_line)
  451. END
  452. CLOSE('Sig')
  453. CLOSE('MSG-Temp'||i)
  454.  
  455. /* Add intermediatary MIME information */
  456.  
  457. OPEN('MSG-Temp'||i, temp_path||'MSG-Temp'||i, 'A')
  458. WRITELN('MSG-Temp'||i, '--NewsRog-Boundary-2000')
  459. WRITELN('MSG-Temp'||i, 'Content-Disposition: Inline; filename='||imagename.i)
  460. WRITELN('MSG-Temp'||i, 'Content-Type:' mime_type||'; name='||imagename.i)
  461. WRITELN('MSG-Temp'||i, 'Content-Transfer-Encoding: Base64')
  462. WRITELN('MSG-Temp'||i, '')
  463. CLOSE('MSG-Temp'||i)
  464.  
  465. /* Insert Base64 Encoded Data */
  466. OPEN('Image', temp_path||imagestext.i, 'R')
  467. OPEN('MSG-Temp'||i, temp_path||'MSG-Temp'||i, 'A')
  468. DO UNTIL EOF('Image')
  469.  image_line = READLN('Image')
  470.  WRITELN('MSG-Temp'||i, image_line)
  471. END
  472. CLOSE('Image')
  473. CLOSE('MSG-Temp'||i)
  474.  
  475.  
  476. /* Add closing MIME information */
  477.  
  478. OPEN('MSG-Temp'||i, temp_path||'MSG-Temp'||i, 'A')
  479. WRITELN('MSG-Temp'||i, '--NewsRog-Boundary-2000')
  480. CLOSE('MSG-Temp'||i)
  481.  
  482. /* Add posts to queue */
  483.  
  484.  
  485. ADDPOST
  486. POSTNUMBER = result
  487.  
  488. /* Set post group */
  489.  
  490. POSTCMD POSTNUMBER SETGROUPS group
  491.  
  492. /* Set post subject */
  493.  
  494. POSTCMD POSTNUMBER SETSUBJ subject ' - ' imagename.i '('||bytes.i 'bytes)'
  495.  
  496. POSTCMD POSTNUMBER INSFILE temp_path||'MSG-Temp'||i
  497.  
  498. /* Clean up temp location */
  499.  
  500. ADDRESS COMMAND
  501. 'run >NIL: delete' temp_path||imagestext.i
  502. 'run >NIL: delete' temp_path||'MSG-Temp'||i
  503.  
  504. ADDRESS (NEWS_PORT)
  505.  
  506. END
  507.  
  508. END
  509.  
  510. /* Multi Part files */
  511.  
  512. ELSE
  513.  
  514. DO
  515.  
  516. /* Check for file splitter */
  517.  
  518. IF ~EXISTS(split_path) THEN
  519. CALL split_path_error()
  520.  
  521. part_size = RTGETSTRING(,'Enter size of parts (in kb):',title)
  522.    part_size = part_size * 1024
  523.  
  524. /* Ask user for subject */
  525.  
  526. subject = RTGETSTRING(,subject_text,title,ok_buttons,)
  527.  
  528. /* Ask user for body text */
  529.  
  530. body = RTGETSTRING(,body_text,title,ok_buttons,)
  531.  
  532. /* Wrap body text to 78 columns */
  533.  
  534. body. = ''
  535. EndPos = length(body); WrapPos = 1
  536.  
  537. DO n = 1 while EndPos <= length(body)
  538.  EndPos = lastpos(' ',body' ', WrapPos + 79)
  539.  body.n = substr(body, WrapPos, EndPos-WrapPos)
  540.  WrapPos = EndPos + 1
  541. end
  542. body.0 = n-1
  543.  
  544. /* Ask user for MIME type setting (default Image/JPEG) */
  545.  
  546. mime_type = RTGETSTRING('Image/JPEG',mime_text,title,ok_buttons,)
  547. IF rtresult = 0 THEN
  548. mime_type = 'Image/JPEG'
  549.  
  550. /* Request files */
  551.  
  552. call rtfilerequest(default_binary_path,,files_text, , "rtfi_flags=freqf_multiselect",files)
  553. IF files = 0 THEN
  554. EXIT
  555.  
  556. /* Enter loop */
  557.  
  558.    DO v=1 to files.count
  559.  
  560.       ADDRESS COMMAND
  561.  
  562.       DivPos = Max(lastpos(':', files.v), lastpos('/', files.v)) +1
  563.       filename.v = substr(files.v, DivPos)
  564.       split_path '"'||files.v||'" S='||part_size '"'||temp_path||filename.v||'.0" >NIL:'
  565.  
  566. /* Determine part names */
  567.  
  568.       'run >nil: list "'||temp_path||filename.v||'.0#?" quick files nohead to pipe:filepartlist'
  569.  
  570.       ADDRESS (NEWS_PORT)
  571.  
  572.       w=1
  573.  
  574.       OPEN('fileparts','pipe:filepartlist','r')
  575.       DO UNTIL EOF('fileparts')
  576.       file_part_name_reversed.w = READLN('fileparts')
  577.       w=w+1
  578.       END
  579.       CLOSE('fileparts')
  580.  
  581.       part_total = w-2
  582.       
  583.  
  584. /* Put file names in correct order */
  585. b = 1
  586.  
  587.       DO a = part_total to 1 by -1
  588.       file_part_name.b = file_part_name_reversed.a
  589.       b=b+1
  590.       END
  591.  
  592. /* Determine sizes of parts */
  593.  
  594.       ADDRESS (NEWS_PORT)
  595.  
  596.       DO z = 1 to part_total
  597.  
  598.       ADDRESS COMMAND
  599.  
  600.        base64_path '"'||temp_path||file_part_name.z||'"' '"'||temp_path||file_part_text.z||'"' base64_args '>NIL:'
  601.  
  602.        'run >nil: list "'||temp_path||file_part_name.z||'" LFORMAT %L to pipe:size'||z
  603.  
  604.        'delete >nil: "'||temp_path||file_part_name.z||'"'
  605.  
  606.       ADDRESS (NEWS_PORT)
  607.       IF OPEN('FileSize', 'pipe:size'||z, 'R') THEN
  608.       bytes.z = READLN('FileSize')
  609.       CLOSE('FileSize') 
  610.      
  611.  
  612. /* Create posts */
  613.  
  614. /* Renumber file name, as .00 is used by some programs as a batch file */
  615.  
  616. IF z > 99 THEN number=z
  617. IF z < 10 THEN number='00'||z
  618. ELSE number='0'||z
  619.  
  620.  
  621. OPEN('MSG-Temp'||z, temp_path||'MSG-Temp'||z, 'W')
  622. WRITELN('MSG-Temp'||z, 'This is a multi-part message in MIME format.')
  623. WRITELN('MSG-Temp'||z, '--NewsRog-Boundary-2000')
  624. WRITELN('MSG-Temp'||z, 'Content-Type: Text/Plain; Charset=ISO-8859-1')
  625. WRITELN('MSG-Temp'||z, 'Content-Transfer-Encoding: 7Bit')
  626. WRITELN('MSG-Temp'||z, '')
  627. CLOSE('MSG-Temp'||z)
  628.  
  629. /* Add body text to message */
  630.  
  631.  OPEN('MSG-Temp'||z, temp_path||'MSG-Temp'||z, 'A')
  632. DO q = 1 to body.0
  633.  WRITELN('MSG-Temp'||z, body.q)
  634. END
  635.  WRITELN('MSG-Temp'||z, '')
  636.  WRITELN('MSG-Temp'||z, filename.v||'.'||number)
  637.  WRITELN('MSG-Temp'||z, '(Multi Part file. Part '||z 'of' part_total||')')
  638.  WRITELN('MSG-Temp'||z, '')
  639.  CLOSE('MSG-Temp'||i)
  640.  
  641. /* Add signature to message */
  642.  
  643. OPEN('Sig', sig_path, 'R')
  644. OPEN('MSG-Temp'||z, temp_path||'MSG-Temp'||z, 'A')
  645. DO UNTIL EOF('Sig')
  646.  sig_line = READLN('Sig')
  647.  WRITELN('MSG-Temp'||z, sig_line)
  648. END
  649. CLOSE('Sig')
  650. CLOSE('MSG-Temp'||z)
  651.  
  652. /* Add intermediatary MIME information */
  653.  
  654. OPEN('MSG-Temp'||z, temp_path||'MSG-Temp'||z, 'A')
  655. WRITELN('MSG-Temp'||z, '--NewsRog-Boundary-2000')
  656. WRITELN('MSG-Temp'||z, 'Content-Disposition: Inline; filename='||filename.v||'.'||number)
  657. WRITELN('MSG-Temp'||z, 'Content-Type:' mime_type||'; name='||filename.v||'.'||number)
  658. WRITELN('MSG-Temp'||z, 'Content-Transfer-Encoding: Base64')
  659. WRITELN('MSG-Temp'||z, '')
  660. CLOSE('MSG-Temp'||z)
  661.  
  662. /* Insert Base64 Encoded Data */
  663. OPEN('Part', temp_path||file_part_text.z, 'R')
  664. OPEN('MSG-Temp'||z, temp_path||'MSG-Temp'||z, 'A')
  665. DO UNTIL EOF('Part')
  666.  part_line = READLN('Part')
  667.  WRITELN('MSG-Temp'||z, part_line)
  668. END
  669. CLOSE('Part')
  670. CLOSE('MSG-Temp'||z)
  671.  
  672.  
  673. /* Add closing MIME information */
  674.  
  675. OPEN('MSG-Temp'||z, temp_path||'MSG-Temp'||z, 'A')
  676. WRITELN('MSG-Temp'||z, '--NewsRog-Boundary-2000')
  677. CLOSE('MSG-Temp'||z)
  678.  
  679. ADDRESS COMMAND
  680.  
  681. 'delete >nil: "'||temp_path||file_part_text.z||'"'
  682.  
  683. ADDRESS (NEWS_PORT)
  684.  
  685. /* Add posts to queue */
  686.  
  687.  
  688. ADDPOST
  689. POSTNUMBER = result
  690.  
  691. /* Set post group */
  692.  
  693. POSTCMD POSTNUMBER SETGROUPS group
  694.  
  695. /* Set post subject */
  696.  
  697. POSTCMD POSTNUMBER SETSUBJ subject ' - ' filename.v '- Multi Part File ('||bytes.z 'bytes) ('||z||'/'||part_total||')'
  698.  
  699. POSTCMD POSTNUMBER INSFILE temp_path||'MSG-Temp'||z
  700.  
  701. /* Clean up temp location */
  702.  
  703. ADDRESS COMMAND
  704. 'run >NIL: delete' temp_path||'MSG-Temp'||z
  705.  
  706. ADDRESS (NEWS_PORT)
  707.  
  708. END
  709.  
  710.    END
  711.  
  712. END
  713.  
  714.  
  715. /* Ask user if they want to post now or later */
  716.  
  717. post_later = RTEZREQUEST(post_query,'Post Now|Post Later',title,'rtez_defaultresponse = 0')
  718.  
  719. IF post_later = 0 THEN
  720. EXIT
  721.  
  722. ISONLINE
  723. online = result
  724. IF online = 1 THEN DO
  725. SENDPOST ALL
  726. EXIT
  727. END
  728.  
  729. go_online = RTEZREQUEST(online_query,'Go Online Now|Post Later',title)
  730. IF go_online = 0 THEN
  731. EXIT
  732.  
  733. ONLINE
  734.  call DELAY(250) /* Cause script to pause to allow NewsRog time to go online */
  735. ISONLINE
  736. online2 = result
  737. IF online2 = 1 THEN DO
  738. SENDPOST ALL
  739. EXIT
  740. END
  741.  
  742. call RTEZREQUEST(offline_text,'Post Later',title)
  743.  
  744. END
  745.  
  746. /* End program */
  747.  
  748. EXIT
  749.  
  750. /* Create function() library_error */
  751.  
  752. library_error:
  753.  
  754. DO
  755.  ADDRESS COMMAND
  756.  'C:RequestChoice PUBSCREEN="Workbench" TITLE="Binary Batch Post by Duncan Taylor (21-Jul-2001)" BODY=" Could not execute Arexx script. *n Please check you have rexxreqtools.library *n and rexxsupport.library installed in Libs:" GADGETS="OK" >NIL:'
  757.  EXIT
  758. END
  759. RETURN
  760.  
  761. newsrog_path_error:
  762.  
  763. DO
  764. CALL RTEZREQUEST(newsrog_path 'not found. Please configure this script','Quit',title)
  765. EXIT
  766. END
  767. RETURN
  768.  
  769. temp_path_error:
  770.  
  771. DO
  772. CALL RTEZREQUEST(temp_path 'not found. Please configure this script','Quit',title)
  773. EXIT
  774. END
  775. RETURN
  776.  
  777. base64_path_error:
  778.  
  779. DO
  780. NL='0A'x
  781. CALL RTEZREQUEST(base64_path 'not found. A Base64 Encoder is required for this script.'|| NL || 'A Base64 Encoder can be found on Aminet (/comm/mail/Base64Coders.lha)','Quit',title)
  782. EXIT
  783. END
  784. RETURN
  785.  
  786. split_path_error:
  787.  
  788. DO
  789. NL='0A'x
  790. CALL RTEZREQUEST(split_path 'not found. A File Splitter is required for Multi Part posts.'|| NL || 'A File Splitter can be found on Aminet (/util/cli/MrSPLIT.lha)','Quit',title)
  791. EXIT
  792. END
  793. RETURN
  794.